package com.sinosoft.system.primary.biz.imp;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sinosoft.system.primary.biz.SysRoleBiz;
import com.sinosoft.system.primary.dao.SysRoleDao;
import com.sinosoft.system.primary.entity.SysRole;
import com.sinosoft.system.util.page.Pagenation;

@Service
@Transactional
public class SysRoleBizImp implements SysRoleBiz{

	private static Logger log = Logger.getLogger(SysRoleBizImp.class);
	
	@Autowired
	private SysRoleDao sysRoleDao;
	
	@Override
	public int insertSysRole(SysRole sysRole) {
		log.info("新增SysRole数据"+sysRole.toString());
		return sysRoleDao.insertSysRole(sysRole);
	}

	@Override
	public int updateSysRole(SysRole sysRole) {
		log.info("更新SysRole数据"+sysRole.toString());
		return sysRoleDao.updateSysRole(sysRole);
	}

	@Override
	public int deleteSysRole(int id) {
		log.info("删除SysRole数据 id="+id);
		return sysRoleDao.deleteSysRole(id);
	}

	@Override
	public SysRole selectSysRole(int id) {
		log.info("根据ID查询SysRole数据 id="+id);
		return sysRoleDao.selectSysRole(id);
	}

	@Override
	public SysRole selectSysRole(List<String> queryKeys,List<Object> queryValues) {
		log.info("查询SysRole数据 ");
		return sysRoleDao.selectSysRole(queryKeys, queryValues);
	}

	@Override
	public int selectCountSysRole() {
		log.info("查询SysRole数据 总数量");
		return sysRoleDao.selectCountSysRole();
	}

	@Override
	public int selectCountSysRole(List<String> queryKeys,List<Object> queryValues) {
		log.info("查询SysRole数据 总数量"+queryKeys.toString());
		return sysRoleDao.selectCountSysRole(queryKeys, queryValues);
	}

	@Override
	public List<SysRole> selectLimitSysRole(int start, int size) {
		log.info("查询SysRole数据 limit数量:start="+start+",size="+size);
		return sysRoleDao.selectLimitSysRole(start, size);
	}

	@Override
	public List<SysRole> selectLimitSysRole(List<String> queryKeys,List<Object> queryValues,int start, int size) {
		log.info("条件查询SysRole数据数量");
		return sysRoleDao.selectLimitSysRole(queryKeys, queryValues, start,  size);
	}

	@Override
	public List<SysRole> selectAllSysRole() {
		log.info("查询所有SysRole数据");
		return sysRoleDao.selectAllSysRole();
	}

	@Override
	public List<SysRole> selectAllSysRole(List<String> queryKeys,List<Object> queryValues) {
		log.info("条件查询所有SysRole数据");
		return sysRoleDao.selectAllSysRole(queryKeys, queryValues);
	}

	@Override
	public Pagenation selectPageSysRole(Pagenation page) {
		log.info("分页查询所有SysRole数据");
		int start =	page.getStartRow();
		int size = page.getPageSize();
		List<SysRole> rows = sysRoleDao.selectLimitSysRole(page.getQueryKeys(), page.getQueryValues(),start,size);
		int total = sysRoleDao.selectCountSysRole(page.getQueryKeys(), page.getQueryValues());
		page.setTotal(total);
		page.setRows(rows);
		return page;
	}
	
	@Override
	public List<SysRole> selectByUserId(int userId) {
		log.info("根据userid查询SysRole数据");
		return sysRoleDao.selectByUserId(userId);
	}

	public SysRoleDao getSysRoleDao() {
		return sysRoleDao;
	}

	public void setSysRoleDao(SysRoleDao sysRoleDao) {
		this.sysRoleDao = sysRoleDao;
	}

	

}
